package card

import "fmt"

// Tcards 切片
type TPlayerCards []*TCards

type TDZPK struct {
	PHandCardList    []TCards //手牌
	PUnderCardList TCards // 5张公共牌
	PUnderCardFlop TCards // 起始三张公牌
	PUnderCardTurn TCards // 转牌
	PUnderCardRiver TCards // 河牌
}

// NewDZPK 新建一个德州扑克类
func NewDZPK() *TDZPK {
	p := &TDZPK{}
	return p
}

// 发牌
func (t *TDZPK) Dealcard(playernum int) {

	pCardHeap := NewCards(52)
	pCardHeap.Print()
	t.PHandCardList = make([]TCards,playernum)
	j := 0
	for i := 0; i < playernum; i++ {
		//每一家发2张底牌
		t.PHandCardList[i] = make(TCards, 2)
		// copy 出来，避免排序时因为slice的特性影响
		copy(t.PHandCardList[i], pCardHeap[j:j+2])
		//发牌完毕，排序手牌
		t.PHandCardList[i].Sort()
		t.PHandCardList[i].Print()
		j = j+2
	}
	//手牌发完，发公共牌
	t.PUnderCardList = make(TCards, 5)
	copy(t.PUnderCardList, pCardHeap[j:j+5])
	//t.PUnderCardList.Print()
	//手牌发完，发公共牌
	t.PUnderCardFlop = make(TCards, 3)
	copy(t.PUnderCardFlop, pCardHeap[j:j+3])
	j = j+3
	fmt.Println("翻牌：",t.PUnderCardFlop.Tostr())
	t.PUnderCardTurn = make(TCards, 1)
	copy(t.PUnderCardTurn, pCardHeap[j:j+1])
	j = j+1
	fmt.Println("转牌：",t.PUnderCardTurn.Tostr())

	t.PUnderCardRiver = make(TCards, 1)
	copy(t.PUnderCardRiver, pCardHeap[j:j+1])
	fmt.Println("河牌：",t.PUnderCardRiver.Tostr())

}
